package com.xckj.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.xckj.dao.JacgSpringTaskMapper;
import com.xckj.entity.JacgSpringTask;
import com.xckj.service.JacgSpringTaskService;
import com.xckj.utils.ReturnT;

/**
 * @description Spring定时任务信息表
 * @author yanchf
 * @date 2023-12-03
 */
@Service
public class JacgSpringTaskServiceImpl implements JacgSpringTaskService {

	@Resource
	private JacgSpringTaskMapper jacgSpringTaskMapper;


	@Override
	public Object insert(JacgSpringTask jacgSpringTask) {

		// valid
		if (jacgSpringTask == null) {
			return ReturnT.error("必要参数缺失");
        }

		jacgSpringTaskMapper.insert(jacgSpringTask);
        return ReturnT.success();
	}


	@Override
	public Object delete(int id) {
		int ret = jacgSpringTaskMapper.delete(id);
		return ret>0?ReturnT.success():ReturnT.error();
	}


	@Override
	public Object update(JacgSpringTask jacgSpringTask) {
		int ret = jacgSpringTaskMapper.update(jacgSpringTask);
		return ret>0?ReturnT.success():ReturnT.error();
	}


	@Override
	public JacgSpringTask load(int id) {
		return jacgSpringTaskMapper.load(id);
	}


	@Override
	public Map<String,Object> pageList(int offset, int pagesize) {

		List<JacgSpringTask> pageList = jacgSpringTaskMapper.pageList(offset, pagesize);
		int totalCount = jacgSpringTaskMapper.pageListCount(offset, pagesize);

		// result
		Map<String, Object> result = new HashMap<String, Object>();
		result.put("pageList", pageList);
		result.put("totalCount", totalCount);

		return result;
	}

}